-
Notifications
You must be signed in to change notification settings - Fork 0
feat(hooks): add PPID capture for terminal tracking #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pass parent process ID to shelltime track command for terminal emulator detection in daemon service. - bash: add --ppid=$PPID to track calls - zsh: add --ppid=$PPID to track calls - fish: capture PPID at startup, add --ppid flag 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to the shelltime tracking system by integrating the Parent Process ID (PPID) into the command tracking data. This addition provides a crucial piece of information for identifying the specific terminal emulator environment from which commands are executed, thereby enriching the context of collected usage statistics and facilitating more precise analysis of shell activity. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds parent process ID (PPID) capturing to the bash, zsh, and fish shell hooks. This is a useful feature for terminal emulator detection. The implementation for bash and fish shells is correct. However, in the zsh hook, there's a potential issue with unquoted variables that could cause problems for commands containing spaces. I've added suggestions to address this.
hooks/zsh.zsh
Outdated
| fi | ||
|
|
||
| shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=pre &> /dev/null | ||
| shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=pre --ppid=$PPID &> /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $CMD variable is not quoted. If a command contains spaces or other special characters (e.g., ls -l), it will undergo word splitting, and the shelltime track command will receive incorrect arguments. To ensure the entire command is passed as a single argument to the -cmd flag, you should double-quote the variable. This is already done correctly in the bash.bash and fish.fish hooks.
shelltime track -s=zsh -id=$SESSION_ID -cmd="$CMD" -p=pre --ppid=$PPID &> /dev/null
hooks/zsh.zsh
Outdated
| return | ||
| fi | ||
| shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=post -r=$LAST_RESULT &> /dev/null | ||
| shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=post -r=$LAST_RESULT --ppid=$PPID &> /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the preexec function, the $CMD variable here should be double-quoted. This will prevent word splitting for commands that contain spaces, ensuring the command is correctly passed to shelltime track.
shelltime track -s=zsh -id=$SESSION_ID -cmd="$CMD" -p=post -r=$LAST_RESULT --ppid=$PPID &> /dev/null
@claude fix the code review issues |
Commands containing spaces (e.g., `ls -l`) would undergo word splitting, causing incorrect arguments to be passed to shelltime track. This aligns with the quoting pattern already used in bash.bash and fish.fish. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Changes
--ppid=$PPIDto track calls--ppid=$PPIDto track callsps -o ppid= -p %self), add--ppid=$FISH_PPIDto track callsRelated PRs
Notes
$PPIDvariablepscommand to get parent PID at shell startup🤖 Generated with Claude Code